const fs = require('fs');

const path = require('path');

// fs.readFile(path.join(__dirname, '/files/1.txt'), 'utf8', (err, data) => {
//     // console.log(data);
//     if (err) return console.log('错误了');
//     console.log('成功了', data);
// })

function readFilePromise(name) {
    return new Promise(function(resolve, reject) {
        fs.readFile(path.join(__dirname, `/files/${name}`), 'utf8', (err, data) => {
            // console.log(data);
            if (err) return reject('错误了');
            resolve(data);
        })
    })
}
readFilePromise('1.txt')
.then(res => {
    console.log(res);
    return readFilePromise('2.txt')
})
.then(res => {
    console.log(res);
    return readFilePromise('3.txt')
})
.then(res => {
    console.log(res);
})